﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ICIA.ARojas.Silverlight.Entities;
using ICIA.ARojas.Visual.Destino.ViewModel;
using System.Windows.Media.Imaging;
using ICIA.ARojas.Visual.CursoRealizado;

namespace ICIA.ARojas.Visual.Destino
{
    public partial class DestinoModal : ChildWindow
    {
        VmDestinoModal viewmodel;

        public DestinoModal()
        {
            InitializeComponent();
        }

        public DestinoModal(Persona persona)
        {
            InitializeComponent();
            viewmodel = new VmDestinoModal(persona);
            this.DataContext = viewmodel;

            this.Show();

            try
            {
                var image = new BitmapImage { UriSource = new Uri(persona.GUID, UriKind.Relative) };
                fotoPersonal.Source = image;
            }
            catch (Exception ex) { }

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            VwCursoRealizado modal = new VwCursoRealizado(viewmodel.PersonaSeleccionada);
            modal.Closed += new EventHandler(modal_Closed);
            modal.Show();
        }

        void modal_Closed(object sender, EventArgs e)
        {            
             viewmodel.CargarCursos();
        }
    }
}

